﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using TCDL.GLOBAL;
using TCDL.BUS;
using TCDL.DAO;

namespace TCDL
{
    public partial class frmChiTietLVC : Form
    {
        gConnect[] gCon = new gConnect[1];
        String MKH;
        public frmChiTietLVC(gConnect[] gCon, String MKH)
        {
            InitializeComponent();
            this.gCon = gCon;
            this.MKH=MKH;
        }

        private void frmChiTietLVC_Load(object sender, EventArgs e)
        {
            gCon[0] = new gConnect("@MaKH", MKH);
            dataGridView1.DataSource = new XemDSBUS().XemDS("XemDKKH", gCon, 1);
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnHuyLich_Click(object sender, EventArgs e)
        {
            string strMaKH = dataGridView1.Rows[SelectedRowIndex].Cells["MaKH"].Value.ToString();
            string strMaLL = dataGridView1.Rows[SelectedRowIndex].Cells["MaLL"].Value.ToString();
            int iMaKH = Int32.Parse(strMaKH);
            int iMaLL = Int32.Parse(strMaLL);
            
            int iCount = 2;
            gConnect[] gCon = new gConnect[iCount];
            gCon[0] = new gConnect("@MaKH", iMaKH);
            gCon[1] = new gConnect("@MaLL", iMaLL);
            XemDSBUS ds = new XemDSBUS();
            ds.ThemDS("Sp_HuyVanChuyen", gCon, iCount);
            frmChiTietLVC_Load(sender, e);
            frmChinh_TimKiem.f.frmChinh_TimKiem_Load(sender, e);
        }
        
        int SelectedRowIndex = -1;
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count > 0)
            {
                SelectedRowIndex = dataGridView1.SelectedCells[0].RowIndex;
            }
       }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}